package cn.neusoft.luofa603.yuejian_29.fragment;


import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import java.util.List;
import cn.neusoft.luofa603.yuejian_29.R;
import cn.neusoft.luofa603.yuejian_29.activity.CourceInfoActivity;
import cn.neusoft.luofa603.yuejian_29.adapter.CourseAdapter;
import cn.neusoft.luofa603.yuejian_29.bean.Course;
import cn.neusoft.luofa603.yuejian_29.model.ClubModel;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

public class CourseFragment extends Fragment {
    private View view;
    private CourseAdapter courseAdapter;
    private RecyclerView recyclerView;



    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {

        view = inflater.inflate(R.layout.fragment_course, container, false);
        initViews();
        initEvents();
        initData();
        return view;
    }
    public void initViews(){
        recyclerView = (RecyclerView) view.findViewById(R.id.cource_rv);
        recyclerView.setLayoutManager(new LinearLayoutManager(this.getActivity()));
        recyclerView.setItemAnimator(new DefaultItemAnimator());

        ClubModel clubModel = new ClubModel();
        Call<List<Course>> call = clubModel.getCource();
        call.enqueue(new Callback<List<Course>>() {
            @Override
            public void onResponse(Call<List<Course>> call, Response<List<Course>> response) {
                final List<Course> mDataList = response.body();
                CourseAdapter courseAdapter = new CourseAdapter(getActivity(),mDataList);
                recyclerView.setAdapter(courseAdapter);
            }

            @Override
            public void onFailure(Call<List<Course>> call, Throwable t) {

             t.printStackTrace();
            }
        });


    }
    public void initEvents() {

    }
            public void initData(){

    }

}
